var auth = require('../config/auth').auth;
var user = require('../controllers/user');
var render = require('../controllers/render');
var article = require('../controllers/article');
var genset = require('../controllers/genset');
module.exports = function(app) {
    app.get('/', [auth(false)], render.index);

    app.get('/article/:id', [auth(false)], render.singleshow);
    app.get('/author/:id', [auth(false)], render.authorArt);

    app.get('/tags/:tag', [auth(false)], render.tagArtshow);

    app.get('/admin', [auth(false)], render.admin);
    app.get('/admin/setting', [auth(false)], render.adminSetting);
    app.get('/admin/logout', [auth(false)], render.adminLogout);
    app.get('/admin/artcreate', [auth()], render.artcreate);
    app.get('/admin/artlist', [auth()], render.artlist);
    app.get('/admin/artupdata', [auth()], render.artupdata);
    app.get('/admin/userlist', [auth()], render.userlist);
    app.get('/admin/userdata/:id', [auth()], render.userdata);
    app.get('/admin/genset', [auth()], render.genset);

    app.post('/api/user/login', [auth(false)], user.signIn);
    app.post('/api/user/changepwd', [auth()], user.changepwd);
    app.post('/api/user/modifyuser', [auth()], user.modifyuser);
    app.post('/api/user/modifyavatar', [auth()], user.modifyavatar);

    app.post('/api/article/create', [auth()], article.create);
    app.post('/api/article/remove', [auth()], article.remove);
    app.post('/api/article/edit', [auth()], article.edit);

    app.post('/api/admin/genset', [auth()], genset.changeglobal);

    // 游客可以访问
    app.post('/api/article/publishList', [auth(false)], article.publishList);
    app.post('/api/article/publishSearch', [auth(false)], article.publishSearch);
    app.post('/api/article/publishHot', [auth(false)], article.publishHot);
    app.post('/api/article/authorArtlist', [auth(false)], article.authorArtlist);

    app.post('/api/article/findbyid', [auth(false)], article.findbyid);
    app.post('/api/article/listByDate', [auth(false)], article.listByDate);

    app.post('/api/upload/user', [auth()], user.upload);
    app.post('/api/upload/genset', [auth()], genset.upload);
};